//
//  ChooseContactVC.swift
//  chat
//
//  Created by 崔世强 on 2024/6/25.
//  Copyright © 2024 崔世强. All rights reserved.
//

import Foundation
import UIKit


class ChooseContactVC: UIViewController {
    
    @IBOutlet weak var collectionView: UICollectionView!
    
    @IBOutlet weak var tableView: UITableView!
    
    lazy var btn:UIButton = {
        let btn = UIButton.init(type: .custom)
        btn.frame = CGRect.init(x: 0, y: 0, width: 60, height: 30)
        btn.setTitle("完成", for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 17)
        btn.setTitleColor(UIColor.gray, for: .normal)
        //        btn.tintColor = RGBA(r: 0.15, g: 0.67, b: 0.16, a: 1.00)
        btn.isEnabled = false
        btn.isUserInteractionEnabled = true
        btn.addTarget(self, action: #selector(rightbuttonTap(button:)), for: UIControl.Event.touchUpInside)
        return btn
    }()
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//        self.title = NSLocalizedString("通讯录", comment: "通讯录")
//        self.tabBarItem.image = UIImage(named: "tstAddressBook_Default")
//        if #available(iOS 13, *) {
//            self.tabBarItem.image = UIImage(systemName: "person.2.square.stack")
//        }
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    @objc func rightbuttonTap(button:UIButton) {
//        let service = GroupService()
//        var ids = [Int]()
//        for chatContact in self.selectedList {
//            ids.append(chatContact.userId)
//        }
//        self.view.makeModalToastActivity(.center)
//        do {
//            try service.createNewGroup(name: nil, createUserId: AppStatusManager.instance.userLoginStatus.1 ?? 0, ids: ids) { (success, msg, groupId) in
//                if success {
//                    DispatchQueue.main.async {
//                        self.view.hideModalToastActivity()
//                        let chatVc = ChatVC()
//                        chatVc.chatType = ChatType.group
//                        chatVc.sessionServerId = groupId
//                        chatVc.sessionName = "群聊"
//                        chatVc.hidesBottomBarWhenPushed = true
//                        self.navigationController?.popViewController(animated: true)
//                        self.navigationController?.pushViewController(chatVc, animated: true)
//                    }
//                } else {
//                    DispatchQueue.main.async {
//                        self.view.hideModalToastActivity()
//                        self.view.makeToast(msg,duration:1,position:.center)
//                    }
//                }
//            }
//        } catch {
//            print(error)
//            DispatchQueue.main.async {
//                self.view.hideModalToastActivity()
//                self.view.makeToast("创建群聊失败",duration:1,position:.center)
//            }
//        }
    }
}
